<template>
  <view class="commission-item">
    <view class="item-header">
      <text class="order-no">订单号：{{item.orderNo}}</text>
      <text class="status" :style="statusStyle">{{statusText}}</text>
    </view>
    <view class="item-content">
      <view class="product-info">
        <image :src="item.productImage" mode="aspectFill" class="product-img"></image>
        <view class="product-detail">
          <text class="product-name">{{item.productName}}</text>
          <text class="product-spec">{{item.productSpec}}</text>
        </view>
      </view>
      <view class="commission-info">
        <text class="amount">¥{{item.amount}}</text>
        <text class="rate">{{item.rate}}%</text>
      </view>
    </view>
    <view class="item-footer">
      <text class="time">{{item.createTime}}</text>
      <text class="commission">佣金：¥{{item.commission}}</text>
    </view>
  </view>
</template>

<script setup>
import { computed } from 'vue'
import { COMMISSION_STATUS_NAMES, COMMISSION_STATUS_STYLES } from '@/constants/distribution'

const props = defineProps({
  item: {
    type: Object,
    required: true
  }
})

const statusText = computed(() => {
  return COMMISSION_STATUS_NAMES[props.item.status] || '未知状态'
})

const statusStyle = computed(() => {
  return COMMISSION_STATUS_STYLES[props.item.status] || {
    color: '#999',
    backgroundColor: '#F5F5F5'
  }
})
</script>

<style lang="scss">
.commission-item {
  background-color: #FFFFFF;
  margin-bottom: 20rpx;
  padding: 20rpx;
  
  .item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20rpx;
    
    .order-no {
      font-size: 24rpx;
      color: #666;
    }
    
    .status {
      font-size: 24rpx;
      padding: 4rpx 16rpx;
      border-radius: 20rpx;
    }
  }
  
  .item-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20rpx;
    
    .product-info {
      display: flex;
      align-items: center;
      flex: 1;
      
      .product-img {
        width: 120rpx;
        height: 120rpx;
        border-radius: 8rpx;
        margin-right: 20rpx;
      }
      
      .product-detail {
        flex: 1;
        
        .product-name {
          font-size: 28rpx;
          color: #333;
          margin-bottom: 10rpx;
          display: block;
        }
        
        .product-spec {
          font-size: 24rpx;
          color: #999;
        }
      }
    }
    
    .commission-info {
      text-align: right;
      
      .amount {
        font-size: 32rpx;
        color: #333;
        font-weight: bold;
        margin-bottom: 10rpx;
        display: block;
      }
      
      .rate {
        font-size: 24rpx;
        color: #D02B29;
      }
    }
  }
  
  .item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 20rpx;
    border-top: 1rpx solid #EEEEEE;
    
    .time {
      font-size: 24rpx;
      color: #999;
    }
    
    .commission {
      font-size: 28rpx;
      color: #D02B29;
      font-weight: bold;
    }
  }
}
</style> 